#leetcode题目80：删除有序数组重复项ii
#难度：中等

#方法：双指针，快慢指针

from typing import List

class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        j=2
        for i in range(2,len(nums)):
            if nums[i]!=nums[j-2]:
                nums[j]=nums[i]
                j+=1
        return j
            


#测试数据
nums=[1,1,1,2,2,3]
#预期输出：5, [1,1,2,2,3]
solution=Solution()
print(solution.removeDuplicates(nums))

nums=[0,0,1,1,1,1,2,3,3]
#预期输出：7, [0,0,1,1,2,3,3]
solution=Solution()
print(solution.removeDuplicates(nums))

